<?php
	header("Content-Type:text/html;charset=utf8");
	//实例化pdo数据库
	$pdo = new PDO('mysql:localhost=127.0.0.1;dbname=kycp;charset=utf8','root','root');
	//接收前台传值
	$name = $_GET['name'];
	$pwd = md5($_GET['pwd']);
	$age = $_GET['age'];
	$sex = $_GET['sex'];
	$phone = $_GET['phone'];
	$id_card = $_GET['id_card'];
	$add_time = time();
	$ip=ip2long($_SERVER['REMOTE_ADDR']);
	//入库sql语句
	$sql = "insert into ceshi(name,pwd,age,sex,phone,id_card,add_time,ip)values('$name','$pwd','$age','$sex','$phone','$id_card','$add_time','$ip')";
	//if判断是否入库成功
	if ($data=$pdo->exec($sql)) {
		echo "<script>alert('添加成功!');location.href='show.php'</script>";
	}else{
		echo "<script>alert('添加失败!');history.go(-1)</script>";
	}
?>